const router = require('koa-router')() // 一边导入一边实例化
// const result = require('../../config/result.js')
// const { regcheck, checking } = require('../../config/checking.js')
// 操作数据库的接口
const { getToken, Addurl } = require('../../config/databaseapi.js')
// 注册接口
router.post('/createnewfolder', async (ctx) => {
  console.log("调用新建文件夹接口")
  let { form } = ctx.request.body;
  // console.log(form);
  let query = `db.collection("study_materials").add({data:${JSON.stringify(form)}})`;
  let res = await new getToken().posteve(Addurl, query)
  // console.log('添加结果', res)
  if (res.errcode === 0) {
    ctx.body = { msg: "添加成功", status: 1 }
  } else {
    ctx.body = { msg: "添加失败", status: 0 }
  }
})

module.exports = router.routes()